CC = g++ -lpthread -rdynamic -pthread -O0 -Wno-deprecated -I. 

CC_OPTIONS= -g 

COMPILEER= $(CC) $(CC_OPTIONS)

BINARIES= main myMain A1test.out A2.1test.out a22.out

tag = -i

ifdef linux
tag = -n
endif

all: $(BINARIES)
	
OBJECT_FILES= Record.o Comparison.o ComparisonEngine.o Schema.o File.o Pipe.o BigQ.o HeapDBFile.o SortedDBFile.o DBFile.o y.tab.o lex.yy.o 

a22.out: $(OBJECT_FILES) test.o
	$(CC) -o a22.out $(OBJECT_FILES) test.o  -lfl
	
A1test.out: $(OBJECT_FILES) A1test.o 
	$(CC) -o A1test.out $(OBJECT_FILES) A1test.o  -lfl

A2.1test.out: $(OBJECT_FILES) A2.1test.o 
	$(CC) -o A2.1test.out $(OBJECT_FILES) A2.1test.o  -lfl
	
main: $(OBJECT_FILES) main.o
	$(CC) -o main $(OBJECT_FILES) main.o -lfl

myMain: $(OBJECT_FILES) myMain.o
	$(CC) -o myMain $(OBJECT_FILES) myMain.o -lfl
	
readLineitem: $(OBJECT_FILES) readLineitem.o
	$(CC) -o readLineitem $(OBJECT_FILES) readLineitem.o -lfl

readLineitemPage: $(OBJECT_FILES) readLineitemPage.o
	$(CC) -o readLineitemPage $(OBJECT_FILES) readLineitemPage.o -lfl

test.o: test.cc
	$(CC) -g -c test.cc
	
A1test.o: A1test.cc
	$(CC) -g -c A1test.cc

A2.1test.o: A2.1test.cc
	$(CC) -g -c A2.1test.cc
	
main.o: main.cc
	$(CC) -g -c main.cc
	
myMain.o: myMain.cc
	$(CC) -g -c myMain.cc

readLineitem.o: readLineitem.cc
	$(CC) -g -c readLineitem.cc
	
readLineitemPage.o: readLineitemPage.cc
	$(CC) -g -c readLineitemPage.cc
	
Comparison.o: Comparison.cc
	$(CC) -g -c Comparison.cc
	
ComparisonEngine.o: ComparisonEngine.cc
	$(CC) -g -c ComparisonEngine.cc
	
DBFile.o: DBFile.cc
	$(CC) -g -c DBFile.cc

HeapDBFile.o: HeapDBFile.cc
	$(CC) -g -c HeapDBFile.cc
	
SortedDBFile.o: SortedDBFile.cc
	$(CC) -g -c SortedDBFile.cc
	
File.o: File.cc
	$(CC) -g -c File.cc

Pipe.o: Pipe.cc
	$(CC) -g -c Pipe.cc

BigQ.o: BigQ.cc
	$(CC) -g -c BigQ.cc

Record.o: Record.cc
	$(CC) -g -c Record.cc

Schema.o: Schema.cc
	$(CC) -g -c Schema.cc
	
y.tab.o: Parser.y
	yacc -d Parser.y
	sed $(tag) y.tab.c -e "s/  __attribute__ ((__unused__))$$/# ifndef __cplusplus\n  __attribute__ ((__unused__));\n# endif/" 
	g++ -c y.tab.c

lex.yy.o: Lexer.l
	lex  Lexer.l
	gcc  -c lex.yy.c

clean: 
	rm -f *.o
	rm -f *.out
	rm -f *.bin
	rm -f y.tab.c
	rm -f lex.yy.c
	rm -f y.tab.h
	rm -f $(BINARIES)
	rm -f readLineitem
	rm -f readLineitemPage
	
